package com.game.chinesechess.piece.specific;


import com.game.chinesechess.piece.chess;
import com.game.chinesechess.util.Point;

public class generalChess extends chess {
    public generalChess(Color color, int x, int y) {
        this.color = color;
        this.point = new Point(x, y);
    }

    @Override
    public Boolean check(chess[][] map, int toX, int toY) {
        int xDistance = Math.abs(this.point.x - toX);
        int yDistance = Math.abs(this.point.y - toY);
        if (this.color == Color.RED)
            return ((xDistance == 0 && yDistance == 1) || (xDistance == 1 && yDistance == 0))
                    && (toX >= 7 && toX <= 9 && toY >= 3 && toY <= 5);
        else
            return ((xDistance == 0 && yDistance == 1) || (xDistance == 1 && yDistance == 0))
                    && (toX >= 0 && toX <= 2 && toY >= 3 && toY <= 5);

    }

    @Override
    public String getName() {
        return this.color == Color.RED ? "帅" : "将";
    }
}
